// pages/component/prod/prod.js
const app = getApp();

Component({
    /**
     * 组件的属性列表
     */
    properties: {

    },

    /**
     * 组件的初始数据
     */
    data: {
        skinTheme: 'normal-skin',
        title:'商城',
        fontColor:'#000000',
        backgroundColor:'#ffffff',
        skinColor:'#000000',
        obj: {
            //默认主题
            'normal-skin':{
              fontColor:'#000000',
              backgroundColor:'#ffffff',
              skinColor:'#000000'
            },
            //黑色主题
            'dark-skin': {
              fontColor: '#ffffff',
              backgroundColor: '#000000',
              skinColor:'#000000'
            },
            //红色主题
            'red-skin': {
              fontColor: '#ffffff',
              backgroundColor: '#ef1033',
              skinColor:'#ef1033'
            },
            //粉色主题
            'pink-skin': {
              fontColor: '#ffffff',
              backgroundColor: '#f56fa6',
              skinColor:'#f56fa6'
            },
            //橘黄主题
            'orange-skin': {
              fontColor: '#ffffff',
              backgroundColor: '#ff8340',
              skinColor:'#ff8340'
            },
            //绿色主题
            'green-skin': {
              fontColor: '#ffffff',
              backgroundColor: '#86b902',
              skinColor:'#86b902'
            },
            //绯红色主题
            'scarlet-skin': {
              fontColor: '#ffffff',
              backgroundColor: '#e85a71',
              skinColor:'#e85a71'
            },
            //蓝色主题
            'blue-skin': {
              fontColor: '#ffffff',
              backgroundColor: '#40baff',
              skinColor:'#40baff'
            }
        },
    },

    /**
     * 组件的方法列表
     */
    methods: {
        setThemeSkin:function(e){
            //设置顶部主题风格
            var skin = e.target.dataset.flag;
            var that = this;
            
            that.setData({
                skin: skin + '-skin',
                skinColor: that.data.obj[skin + '-skin'].skinColor
            })
            
            wx.setStorage({
                key: "skin",
                data: that.data.obj[skin + '-skin']
            })
    
            app.setThemeSkin(that);
            // wx.showToast({
            //     title:'主题设置成功，刷新页面后生效！',
            //     icon:'none',
            //     duration:2000
            // })

            this.triggerEvent('callParent', '子组件的数据')
        }
    },
    ready:function(){
      app.setThemeSkin(this);
    }
})
